CC = gcc
PP = gcc
AR = ar rcv
ifeq ($(windir),)
EXE =
RM = rm -f
RMDIR = rm -rf
else
EXE = .exe
RM = del
RMDIR = rmdir /Q /S
endif

CFLAGS = -O2 -Os -fno-exceptions -fvisibility=hidden -ffunction-sections -fdata-sections -Wextra -fno-exceptions
INC = -I.

all:bzlib.o crctable.o compress.o decompress.o randtable.o blocksort.o huffman.o

bzlib.o:bzlib.c
	$(CROSS_COMPILE)$(PP) -o $@ $(CFLAGS) -c $< $(INC)

crctable.o:crctable.c
	$(CROSS_COMPILE)$(PP) -o $@ $(CFLAGS) -c $< $(INC)

compress.o:compress.c
	$(CROSS_COMPILE)$(PP) -o $@ $(CFLAGS) -c $< $(INC)

decompress.o:decompress.c
	$(CROSS_COMPILE)$(PP) -o $@ $(CFLAGS) -c $< $(INC)

randtable.o:randtable.c
	$(CROSS_COMPILE)$(PP) -o $@ $(CFLAGS) -c $< $(INC)

blocksort.o:blocksort.c
	$(CROSS_COMPILE)$(PP) -o $@ $(CFLAGS) -c $< $(INC)

huffman.o:huffman.c
	$(CROSS_COMPILE)$(PP) -o $@ $(CFLAGS) -c $< $(INC)

clean:
	-$(RM) $(all)
